home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: netcom.com!timmyd
- From: timmyd@netcom.com (Tim DeBenedictis)
- Subject: Re: How do I use abs() on floats ?
- Message-ID: <timmydDn73Ct.C6r@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- X-Newsreader: TIN [version 1.2 PL1]
- References: <4ghki0$b44@LNCSEX0003.eu.btco.com>
- Date: Thu, 22 Feb 1996 20:53:16 GMT
- Sender: timmyd@netcom21.netcom.com
-
- Use fabs() instead of abs().
-
- -Tim DeBenedictis
- timmyd@netcom.com
-
- PS You could always write your own FABS macro, too; might be faster than
- fabs() but I doubt it:
-
- #define FABS(x) (x>0.0?x:-x)
-
-
-
-
- DaveMx wrote:
- : What's the easiest way to get the absolute scalar value of a float.
- : I need to test to see of a variable is 'bigger' than a certain tolerance.
-
- : e.g.
-
- : if ( abs (error__float) > MAX_TOLERANCE ) printf ( "Tolerance level exceeded \n" );
-
-
- : BUT the abs() function says it only works on int 's . Any ideas how to do it for floats in the most elegant way ???
-